package Structural_design_pattern.Proxy_Pattern;

public class PermissionProxy implements AbstractPermission {
    private RealPermission realPermission = new RealPermission();
    private int level  = 0;

    public void modifyUserInfo(){
        if(0==level){
            System.out.println("对不起，您没有权限修改用户信息");
        }
        if(1==level){
            realPermission.modifyUserInfo();
        }
    }   

    public void viewNote(){
       realPermission.viewNote();
    }

    public void publishNote(){
        if(0==level){
            System.out.println("对不起，您没有权限发布帖子");
        }
        if(1==level){
            realPermission.publishNote();
        }
    }

    public void modifyNote(){
        if(0==level){
            System.out.println("对不起，您没有权限修改帖子");
        }
        if(1==level){
            realPermission.modifyNote();
        }
    }

    public void setLevel(int level){
        this.level = level;
    }

}
